package com.example.springbootrabbitmq.demo3exchangetopic;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class TopicSender {

    @Autowired
    private AmqpTemplate rabbitTemplate;

    public void send() {
        String msg1 = "I am topic.message msg1======";
        System.out.println("sender1: " + msg1);
        rabbitTemplate.convertAndSend("topicExchange", "topic.message", msg1);

        String msg2 = "I am topic.message2 msg2######";
        System.out.println("sender2: " + msg2);
        rabbitTemplate.convertAndSend("topicExchange", "topic.message2", msg2);
    }

}
